<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/vue@next"></script>
    <style>
        .area {
            position: absolute;
            width: 200px;
            height: 300px;
            top: 50%;
            left: 50%;
            background-color: teal;
            transform: translate(-50%, -50%);
        }

        .mask {
            position: absolute;
            top: 0;
            left: 0;
            bottom: 0;
            right: 0;
            background-color: rgb(167, 167, 167);
            opacity: .5;
            font-size: 50px;
            color: #fff;
        }
    </style>
</head>

<body>
    <div id="app"></div>

</body>
<script>
    let vm = {
        // 后续开发页面过程中肯定会出现组件嵌套的方式
        // 但是有一个弹窗（希望可以挂到body上）确保整个mask是覆盖整个页面
        // 如此处，假设area是一个组件
        template: `
            <div class="area">
                <button @click="handle">点击</button>
                <teleport to="body">
                <div class="mask" v-show="show">hello</div>
                </teleport>
            </div>
                `,
        setup () {
            const { ref } = Vue
            let show = ref(false)
            let handle = () => { show.value = !show.value }
            return { show, handle }
        }
    }
    let app = Vue.createApp(vm)
    app.mount('#app')
</script>

</html>